package com.xyz.study.design_mode.t_flyweight;

import com.xyz.study.design_mode.t_flyweight.mode.Printer;
import com.xyz.study.design_mode.t_flyweight.mode.PrinterFlyweightFactory;

/**
 * 避免浪费：其一 ---- Flyweight 轻量级模式
 * 通过尽量共用实例，来避免new出对象（池化资源复用对象）
 * @author XYZ
 * @version 1.0.0
 * @since 2020/6/22
 */
public class FlyweightMain {

    public static void main(String[] args) {
        PrinterFlyweightFactory flyweightFactory = new PrinterFlyweightFactory();
        Printer printer = flyweightFactory.getPrinter("linux");
        if (printer != null){
            printer.printAddress(printer.findAddress());
        }
    }
}
